<?php

namespace app\modules\admin\models;

use Yii;

/**
 * This is the model class for table "admin_role_access".
 *
 * @property int $id
 * @property string $role_id 角色id
 * @property string $access_sn 权限sn
 * @property string $created 创建时间
 * @property string $modified 修改时间
 * @property int $deleted 0未删除 1已删除
 */
class AdminRoleAccess extends BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'admin_role_access';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['role_id', 'access_sn'], 'required'],
            [['created', 'modified'], 'safe'],
            [['deleted'], 'integer'],
            [['role_id', 'access_sn'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'role_id' => Yii::t('app', '角色id'),
            'access_sn' => Yii::t('app', '权限sn'),
            'created' => Yii::t('app', '创建时间'),
            'modified' => Yii::t('app', '修改时间'),
            'deleted' => Yii::t('app', '0未删除 1已删除'),
        ];
    }

    public function getAccessByRoleId(array $roleId){
        return $this->orm()
            ->andWhere(['in','role_id',$roleId])
            ->asArray()
            ->all();
    }
}
